<template>

	<div style="width: 1100px;">

		<el-breadcrumb separator="/">
			<el-breadcrumb-item :to="{  path: '/adminHome' }">首页</el-breadcrumb-item>
			<el-breadcrumb-item><a href="/adminHome">业务审核</a></el-breadcrumb-item>
			<el-breadcrumb-item>项目审核</el-breadcrumb-item>
		</el-breadcrumb>

		<el-card class="box-card" style="width: 1200px; margin-top: 1.875rem; margin-right: -100px;">
			<div style="float: left; margin-top:1.875rem ;">
				<el-input type="txte" v-model="queryInfo.username" placeholder="请输入内容"
					style="width: 200px;height: 50px;"></el-input>
				<el-button type="primary" icon="el-icon-search" @click="queryAll">查询</el-button>
			</div>


			<el-table :data="tableData" border style="width: 100%">

				<el-table-column prop="projectName" label="项目名称">
				</el-table-column>
				<el-table-column prop="user.name" label="发起人">
				</el-table-column>
				<el-table-column prop="projectAllMoney" label="目标金额">
				</el-table-column>
				<el-table-column prop="projectAddTime" label="开始时间">
				</el-table-column>
				<el-table-column prop="projectEndTime" label="结束时间">
				</el-table-column>
				</el-table-column>
				<el-table-column prop="istg" label="状态">
					<template slot-scope="scope">
						<span v-if="scope.row.istg==1">审核中</span>
						<span v-if="scope.row.istg==2">通过审核</span>
						<span v-if="scope.row.istg==3">审核失败</span>
						<span v-if="scope.row.istg==4">众筹中</span>
						<span v-if="scope.row.istg==5">众筹失败</span>
						<span v-if="scope.row.istg==6">众筹成功</span>
					</template>
				</el-table-column>


				<el-table-column label="操作" width="200px">
					<template slot-scope="scope">
						<el-tooltip class="item" effect="dark" content="通过审核" placement="top-start">
							<el-button type="success" icon="el-icon-finished"
								@click.once="tongguo(scope.row.projectId,2)" v-show="scope.row.istg==1">
							</el-button>
						</el-tooltip>

						<el-tooltip class="item" effect="dark" content="审核失败" placement="top-start">
							<el-button type="success" icon="el-icon-s-release"
								@click.once="tongguo(scope.row.projectId,3)" v-show="scope.row.istg==1">
							</el-button>
						</el-tooltip>

						<el-tooltip class="item" effect="dark" content="查看回报" placement="top-start">
							<el-button type="success" icon="el-icon-s-order" @click="tongguo1(scope.row.projectId)">
							</el-button>
						</el-tooltip>

						<el-tooltip class="item" effect="dark" content="删除项目" placement="top-start">
							
							<el-button type="success" icon="el-icon-delete-solid"
								v-show="scope.row.istg==5||scope.row.istg==6" @click="deleteproject(scope.row.projectId)" >
							</el-button>
						</el-tooltip>


					</template>

				</el-table-column>
			</el-table>


			<!-- 分页 -->

			<el-pagination @current-change="handleCurrentChange" :current-page="queryInfo.pageNum"
				:page-sizes="[1, 4, 8, 10]" :page-size="3" layout="total, prev, pager, next, jumper" :total="total">
			</el-pagination>


		</el-card>

		<!-- 查看回报 -->
		<el-dialog title="添加分类" :visible.sync="retudvisible">

			<el-table :data="tableData1" border style="width: 100%">

				<el-table-column prop="retuId" label="回报ID">
				</el-table-column>
				<el-table-column prop="retuType" label="回报类型">
					<template slot-scope="scope">
						<span v-if="scope.row.retuType==0">线上</span>
						<span v-if="scope.row.retuType==1">实物</span>
					</template>
				</el-table-column>
				<el-table-column prop="payMoney" label="支付金额">
				</el-table-column>
				<el-table-column prop="retuText" label="回报内容">
				</el-table-column>
				<el-table-column prop="img" label="图片">
					<template slot-scope="scope">
						<el-image style="width: 50px; height: 50px"
							:src="'http://localhost:8080/vueload?filename='+scope.row.img" :fit="fit">
						</el-image>
					</template>
				</el-table-column>
				</el-table-column>
				<el-table-column prop="retuNumber" label="回报数量">

				</el-table-column>

				<el-table-column prop="syNumber" label="剩余数量">
				</el-table-column>
				<el-table-column prop="retuTime" label="回报时间">
				</el-table-column>
				<el-table-column prop="limits" label="限购">
				</el-table-column>
				<el-table-column prop="isEmail" label="邮费">
				</el-table-column>


			</el-table>



			<div slot="footer" class="dialog-footer">
				<el-button @click="resetForm()">确定</el-button>
			</div>
		</el-dialog>




	</div>
</template>
<script>
	export default {
		data() {
			return {
				retudvisible: false,
				tableData: [],
				tableData1: [],
				queryInfo: {
					pageNum: 1,
					username: '',
					total: 0
				}

			}
		},
		methods: {

			//重置
			resetForm(formName) {
				this.retudvisible = false
			},

			//删除项目
			deleteproject(id) {
				this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(async () => {
					var res = await this.$http.post('deleteProjectByProjectId?projectId=' + id);
					if (res.data.code == 200) {
						this.queryAll()
						this.$message({
							type: 'success',
							message: '删除成功!'
						});
					}

				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});


			},

			// 查看回报
			async tongguo1(id) {


				var res = await this.$http.get('selectRetuTableByPId?projectId=' + id)
				this.tableData1 = res.data.data
				this.retudvisible = true


			},

			// 通过审核
			async tongguo(id, istg) {
				alert(istg)
				var param = new URLSearchParams();
				param.append('projectId', id)
				param.append('istg', istg)
				var res = await this.$http.post('updateProjectistg', param);
				if (res.data.code == 200) {
					this.$message(res.data.message)
					this.queryAll()
				} else {
					this.$message.error(res.data.message)
				}

			},


			//查询全部
			async queryAll() {

				var param = new URLSearchParams();
				param.append('pageNum', this.queryInfo.pageNum)
				param.append('name', this.queryInfo.username)
				var res = await this.$http.post('queryProjectAll', param)
				this.tableData = res.data.data.list
				this.total = res.data.data.total
			},
			// 页码大小
			handleSizeChange(val) {
				console.log(`每页 ${val} 条`);
			},
			// 页码变动
			handleCurrentChange(val) {
				this.queryInfo.pageNum = val;
				this.queryAll();
			}

		},
		async mounted() {
			this.queryAll()

		}
	}
</script>

<style>
</style>
